
package com.chinaoly.sdk.base;

import android.databinding.ViewDataBinding;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;

import com.chinaoly.sdk.R;


/**
 *默认的activity 的基类
 */
public abstract class BaseActivity<Binding extends ViewDataBinding> extends TitleNotImplActivity<Binding> {


    /**
     * 标题
     */
    private TextView tvTitle;

    /**
     * toolbar
     */
    private Toolbar bar;

    @Override
    protected int getTitleLayoutId() {
        return R.layout.toolbar;
    }

    @Override
    protected void bindTitleViewId(View view) {
        bar = view.findViewById(R.id.toolbar);
        tvTitle = view.findViewById(R.id.tv_title);
    }
    @Override
    protected void setLeftCallBack(View.OnClickListener listener) {
        if (bar != null) {
            bar.setNavigationOnClickListener(listener);
        }
    }
    protected void setTitleInfo(String title) {
        if (tvTitle != null) {
            tvTitle.setText(title);
        }
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setLeftCallBack(view->{
            onBackPressed();
        });
    }
}
